/**
 * @author wangpeizhi
 */
import request from '@/utils/request'

/**
 * 查询角色树
 * @param {*} query
 */
export function roleList(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/queryPage',
    method: 'post',
    data
  })
}

/**
 * 获取角色对应用户列表
 * @param {*} query
 */
export function userList(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/queryRoleUser',
    method: 'post',
    data
  })
}

/**
 * 查询角色列表
 * @param {*} query
 */
export function queryUserRole(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: '/backend/sysUserLogin/queryPage',
    method: 'post',
    data
  })
}

/**
 * 为角色添加用户
 * @param {*} roleId
 * @param {*} userIds
 */
export function insertRoleUser(roleId, userIds) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/insertRoleUser',
    method: 'get',
    params: {
      roleId,
      userIds
    }
  })
}

/**
 * 删除角色权限用户
 * @param {*} ids
 * @param {*} roleId
 */
export function deleteUser(ids, roleId) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/deleteRoleUser',
    method: 'get',
    params: {
      ids,
      roleId
    }
  })
}
/**
 * 查询模块权限树
 */
export function queryMenu(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/menu/queryMenu',
    method: 'post',
    data
  })
}
/**
 * 保存角色权限
 * @param {*} roleId
 * @param {*} resIds
 */
export function saveMenu(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/insertRoleMenus',
    method: 'post',
    data
  })
}
/**
 * 角色现有权限
 * @param {*} id
 */
export function getData(data) {
  return request({
    baseURL: '/API-ENTERPRISE-BACKEND/',
    url: 'backend/role/queryRoles',
    method: 'post',
    data
  })
}
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
